<%@page import="java.util.*,com.hdl.entity.*"%>
<%@ page language="java" pageEncoding="UTF-8"%><!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
<jsp:include page="/admin/head.jsp"></jsp:include>
  
</head>
<body>
<jsp:include page="/admin/header.jsp"></jsp:include> 
<jsp:include page="/admin/left-menu.jsp?leftMenu=3"></jsp:include>
<jsp:include page="/admin/footer.jsp"></jsp:include>

  
    <!--中间-->
    <section style="padding-top: 60px">
     <nav aria-label="breadcrumb">
			<ol class="breadcrumb">
				<li class="breadcrumb-item">管理首页</li>
				<li class="breadcrumb-item">产品中心</li>
				<li class="breadcrumb-item">产品管理</li>
			</ol>
		</nav>
      <%
      int roleid = (int)request.getAttribute("roleid");
      %>
      <form class="form-inline" action="admin/mall-list.let">
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">商品类别：</label>
          <select class="form-control" name="roleid">
            <option value="">全部商品</option>
            <option value="1" <%= roleid == 1 ? "selected=\"selected\"":"" %> >锅底</option>
            <option value="2" <%= roleid == 2 ? "selected=\"selected\"":"" %>>涮菜</option>
            <option value="3" <%= roleid == 3 ? "selected=\"selected\"":"" %> >特色蘸料</option>
            <option value="4" <%= roleid == 4 ? "selected=\"selected\"":"" %> >小吃甜品</option>
            <option value="5" <%= roleid == 5 ? "selected=\"selected\"":"" %> >特色饮品</option>
          </select>
        </div>
        <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">关键字：</label>
          <input type="text" class="form-control" placeholder="搜索关键字" name="like" value="${like}">
        </div>
        <button type="submit" class="btn btn-primary mb-2"><i class="fa fa-search"></i></button>
         <div class="form-group mx-sm-1 mb-2">
          <label class="sr-only">数量：</label>
          <%
          int pageSize = (int)request.getAttribute("rowMax");
          %>
          <select name="pageSize" class="form-control">
            <option value="5" selected="selected">每页5条</option>
            <option value="10" <%= pageSize == 10 ? "selected=\"selected\"":"" %>>每页10条</option>
            <option value="20" <%= pageSize == 20 ? "selected=\"selected\"":"" %>>每页20条</option>
            <option value="50" <%= pageSize == 50 ? "selected=\"selected\"":"" %>>每页50条</option>
          </select>
        </div>
        <a href="admin/mall/mall-add.jsp" class="btn btn-success ml-auto mr-2"><i class="fa fa-plus"></i></a>
      </form>
<div class="ml-2 mr-2">
<table class="table table-striped table-bordered table-hover" >
  <thead>
    <tr>
      <th scope="col">商品名称</th>
      <th scope="col">类型</th>
      <th scope="col">价格（元）</th>
      <th scope="col">图片</th>
       <th scope="col">介绍</th>
        <th scope="col">积分</th>
       <th scope="col">操作</th>
    </tr>
  </thead>
  
  <%
      List<MallProduct> list = (List)request.getAttribute("list");
      
     for(int i=0;i<list.size();i++){
    	 MallProduct m = list.get(i);
    	 %>
    
   
    	 
     <tr>
      <th scope="col"><%=m.getMallProductName()%></th>
      <th scope="col"><% 
      if(m.getMallTypeId()==1){ out.write("锅底");}
      if(m.getMallTypeId()==2){ out.write("涮菜");}
      if(m.getMallTypeId()==3){ out.write("特色蘸料");}
      if(m.getMallTypeId()==4){ out.write("小吃甜品");}
      if(m.getMallTypeId()==5){ out.write("特色饮品");}
      %></th>
      <th scope="col"><%=m.getMallProductPrice1() %></th>
      <th scope="col"><img alt="" src="<%=m.getMallProductPath() %>" style=" width: 100px; height: 100px " ></th>
      <th scope="col"><%=m.getMallProductMs() %></th>
      <th scope="col"><%=m.getMallProductScore()%></th>
      <td>
			<div class="dropdown">
  				<button class="btn btn-outline-primary btn-block dropdown-toggle" type="button" data-toggle="dropdown">
  				操作
  			</button>
  				<div class="dropdown-menu dropdown-menu-right">
    				<a class="dropdown-item" href="admin/mallproduct-update1.let?updateid=<%=m.getMallProductId() %>">修改</a>
    				<a class="dropdown-item hssdelete" href="javascript:;" onclick="delelt('<%=m.getMallProductId() %>')">删除</a>
  				</div>
			</div>
		</td>
    </tr>
    	 
     <% }
  %>	 
  
    
  <tbody>
  
  </tbody>
</table>
 <%

int total = (int)request.getAttribute("total");
int pageMax=(int)(total-1)/pageSize+1;

int current = 1;
try{
	current = Integer.valueOf(request.getParameter("current"));
}catch(Exception ex){
}

%>
<h6>总计:<%=total %>条数据,共:<%=pageMax %>页</h6>
<ul class="pagination justify-content-center">
	<li class="page-item"><a class="page-link" href="admin/mall-list.let?current=<%=1%>&pageSize=<%=pageSize%>&like=${like}&roleid=${roleid}"> <span aria-hidden="true">&laquo;</span></a></li>
<%for(int i=1;i<=pageMax;i++) { %>
	<li class="page-item <%=current==i?"active":""%>"><a class="page-link" href="admin/mall-list.let?current=<%=i%>&pageSize=<%=pageSize%>&like=${like}&roleid=${roleid}"><%=i %></a></li>
<%} %>
	<li class="page-item"><a class="page-link" href="admin/mall-list.let?current=<%=pageMax%>&pageSize=<%=pageSize%>&like=${like}&roleid=${roleid}">&raquo;</span></a></li>
</ul>	
</div>
    
    
    
 
</div>    
    

</section>

</body>
</html>

<script>

   function delelt(i) {
	   
	   sys.confirm("确定删除该商品吗？",function(r){
		   
		   if(r){
			   
			   
			    $.get(
				      "admin/mallproduct-delelt.let",
				      {id:i},
				      function (date) {
				    	  
				    	  if(date.code == 200){
				    		  
				    		  sys.toastr.success("删除成功");
				    	  }
				    	  
				      }
						
					 ,"json"
					)
					
					
		   }
		   
	   });
	   
	   
	   
	  
			
			
		     
		   
	   }
	


</script>